package br.ufmg.dees.insane.ui.rich.postp.postp_view;

import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class GridBagLayoutView extends JFrame {

	/**   */
	private static final long serialVersionUID = 1L;
	
	private JPanel container;
	private GridBagLayout layout;
	private GridBagConstraints constraints;

	private JButton edgesButton; 
	private JButton vertexButton; 
	private JButton halfEdgeButton; 
	private JButton okButton; 
	private JTextField textField;
	private JComboBox fontCombo;
	private JButton plusButton;
	private JTextField plusField;
	private JButton minusButton;
	private JTextField minusField;
	private JTextField stepField;

	public GridBagLayoutView(){
		super();
		//container = this.getContentPane();
		layout = new GridBagLayout();
		container.setLayout(layout);
		
		constraints = new GridBagConstraints();
		
		edgesButton = new JButton("Edges");
		vertexButton = new JButton("Vertex");
		halfEdgeButton = new JButton("HalF-Edges");
		okButton = new JButton("OK");
		
		//textField.add(new JLabel("Text"));
		textField = new JTextField();
		
		//fontCombo.add(new JLabel("Font"));
		String[] textFontStr = new String[5];
	    textFontStr[0] = "Arial";
	    textFontStr[1] = "Monospaced";
	    textFontStr[2] = "SansSerif";
	    textFontStr[3] = "Time"; 
	    textFontStr[4] = "NONE"; 
	    fontCombo = new JComboBox(textFontStr);
		
	  //  plusButton.add(new JLabel("step"));
	    plusButton = new JButton("+");
	    
	 //   minusButton.add(new JLabel("step"));
	    minusButton = new JButton("-");
		    
	   // stepField.add(new JLabel("Set step"));
	    stepField = new JTextField();
	    
	    plusField = new JTextField();
	    minusField = new JTextField();
	    
	    //adicionando os componentes no GridBagLayout 
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(edgesButton,0,0,3,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(vertexButton,1,0,3,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(halfEdgeButton,2,0,3,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(okButton,3,0,3,1);
	    
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(new JLabel("text"),4,0,1,1);
	  
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(textField,4,1,2,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(new JLabel("Font"),5,0,1,1);
	  
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(fontCombo,5,1,2,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(new JLabel("step +"),6,0,1,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(plusButton,6,1,1,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(plusField,6,2,1,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(new JLabel("step -"),7,0,1,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(minusButton,7,1,1,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(minusField,7,2,1,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(new JLabel("Set Step"),8,0,1,1);
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(stepField,8,1,2,1);
	  
	    
	    /*  
	    
	    
	    
	    
	    constraints.fill = GridBagConstraints.BOTH;
	    addComponent(stepField,8,0,3,1);
	   */ 
	   // setSize(300,400);
	//    setVisible(true);
		
	}
		
	private void addComponent(Component component, int row, int column, int width, int height){
		constraints.gridx = column;
		constraints.gridy = row;
		
		constraints.gridwidth = width;
		constraints.gridheight = height;
		
		layout.setConstraints(component, constraints);
		container.add(component);
		
		
	}
		
		
		
		
		
		
		
	
}

